package com.house.api.controller;

import com.house.common.result.Result;
import com.house.model.dto.HistoryDto;
import com.house.model.vo.HouseVo;
import com.house.service.service.IHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/history")
@Api(tags = "浏览历史相关接口",value = "浏览历史相关接口")
public class HistoryController {

    @Autowired
    private IHistoryService historyService;

    @PostMapping("/add/{houseId}")
    @ApiOperation(value = "新增历史记录")
    public Result addHistory(@PathVariable("houseId") String houseId) {
        historyService.addHistory(houseId);
        return Result.ok();
    }

    @GetMapping
    @ApiOperation(value = "查询所有的历史记录")
    public Result getHistory() {
        List<HouseVo> history = historyService.getHistory();
        return Result.ok(history);
    }

    @GetMapping("/count")
    @ApiOperation(value = "查询历史记录数量")
    public Result getHistoryCount() {
        int historyCount = historyService.getHistoryCount();
        return Result.ok(historyCount);
    }
}
